package com.derbysoft.ota.application.translator.rs;

import java.util.Map;

import com.derbysoft.modules.eip.translator.Translator;
import com.derbysoft.ota.interfaces.protocol._2009a.TransactionStatusType;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;

public class TransactionStatusTypeTranslator implements Translator<com.derbysoft.remote.dswitch.generic.constants.TransactionStatusType, TransactionStatusType> {

	@Override
	public TransactionStatusType translate(
		com.derbysoft.remote.dswitch.generic.constants.TransactionStatusType source) {

		Map<com.derbysoft.remote.dswitch.generic.constants.TransactionStatusType, TransactionStatusType> map = map();
		TransactionStatusType dest = map.get(source);
		Preconditions.checkArgument(
			dest != null,
			"Unsupported TransactionStatusType [" + source + "], possible values are : " + map.keySet()
		);
		return dest;
	}

	private Map<com.derbysoft.remote.dswitch.generic.constants.TransactionStatusType, TransactionStatusType> map() {
		return ImmutableMap.of(
			com.derbysoft.remote.dswitch.generic.constants.TransactionStatusType.IGNORED, TransactionStatusType.IGNORED, 
			com.derbysoft.remote.dswitch.generic.constants.TransactionStatusType.INITIATED, TransactionStatusType.IGNORED, 
			com.derbysoft.remote.dswitch.generic.constants.TransactionStatusType.COMMITTED, TransactionStatusType.COMMITTED, 
			com.derbysoft.remote.dswitch.generic.constants.TransactionStatusType.UNSUCCESSFUL, TransactionStatusType.UNSUCCESSFUL 
		);
	}

}
